package com.eltonkent.dashboard.util;

public class MathUtil {

	public static double round(double number, int numberOfDecimal) {
		StringBuilder round = new StringBuilder("1");
		for (int i = 0; i < numberOfDecimal; i++) {
			round.append('0');
		}
		int precision = Integer.parseInt(round.toString());
		return Math.floor(number * precision + .5) / precision;
	}

	public static double round(float number, int numberOfDecimal) {
		StringBuilder round = new StringBuilder("1");
		for (int i = 0; i < numberOfDecimal; i++) {
			round.append('0');
		}
		int precision = Integer.parseInt(round.toString());
		return Math.floor(number * precision + .5) / precision;
	}
}
